package rin.cq.tho;


import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.tencent.bugly.crashreport.CrashReport;

public class BuglyTest extends AppCompatActivity {
    Button java,anr,nat;
    String TAG="重庆 THO BuglyTester";
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.bugly_test);
        CrashReport.setIsDevelopmentDevice(getApplicationContext(), true);
        CrashReport.initCrashReport(getApplicationContext());
        java=findViewById(R.id.test_java);
        anr=findViewById(R.id.test_anr);
        nat=findViewById(R.id.test_native);
        java.setOnClickListener(new BuglyFunc());
        anr.setOnClickListener(new BuglyFunc());
        nat.setOnClickListener(new BuglyFunc());
    }

    private class BuglyFunc implements View.OnClickListener{
        @Override
        public void onClick(View v) {
            if (v==java) {
                Log.e(TAG,"测试Java崩溃");
                CrashReport.testJavaCrash();
            } else if (v==anr) {
                Log.e(TAG,"测试ANR未响应");
                CrashReport.testANRCrash();
            } else if (v==nat){
                Log.e(TAG,"测试Native崩溃");
                CrashReport.testNativeCrash();
            }
        }
    }
}
